package com.atwisdom.star.common.util;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fastjson.JSONObject;
import jodd.util.StringUtil;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
 * 动态数据源工具类
 */
public class DataSourceUtil {

    public static DruidDataSource buildDataSource(DruidDataSource master, JSONObject values) {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName(values.getString("datasource_driver"));
        dataSource.setUrl(values.getString("datasource_url"));
        dataSource.setUsername(values.getString("datasource_username"));
        dataSource.setPassword(values.getString("datasource_password"));
        dataSource.setConnectProperties(master.getConnectProperties());
        return dataSource;
    }
}
